""" pyhotp unit test

"""

import unittest
import pytotp

class TestStandardValue(unittest.TestCase):
    """ from RFC6238
    """
    def test_sha1(self):  
        secret = "12345678901234567890"
        digit = 8
        T0 = 0
        X = 30
        standardvalue = { 59:94287082, 1111111109:7081804, 1111111111:14050471, 
                          1234567890:89005924, 2000000000:69279037, 20000000000:65353130 
                        }
        
        myotp = pytotp.TOTP("sha1", secret, digit, T0, X)
        for counter in standardvalue.keys():
            self.assertTrue(myotp.generateTOTP(counter) == standardvalue[counter],
                    "Error count is %d ." % counter)
     
    def test_sha256(self):  
        secret = "12345678901234567890123456789012"
        digit = 8
        T0 = 0
        X = 30
        standardvalue = { 59:46119246, 1111111109:68084774, 1111111111:67062674, 
                          1234567890:91819424, 2000000000:90698825, 20000000000:77737706 
                        }
        
        myotp = pytotp.TOTP("sha256", secret, digit, T0, X)
        for counter in standardvalue.keys():
            self.assertTrue(myotp.generateTOTP(counter) == standardvalue[counter],
                    "Error count is %d ." % counter)

    def test_sha512(self):  
        secret = "1234567890123456789012345678901234567890123456789012345678901234"
        digit = 8
        T0 = 0
        X = 30
        standardvalue = { 59:90693936, 1111111109:25091201, 1111111111:99943326, 
                          1234567890:93441116, 2000000000:38618901, 20000000000:47863826 
                        }
        
        myotp = pytotp.TOTP("sha512", secret, digit, T0, X)
        for counter in standardvalue.keys():
            self.assertTrue(myotp.generateTOTP(counter) == standardvalue[counter],
                    "Error count is %d ." % counter)

